/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ipccenter.toster.jpa;



import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.List;
import javax.persistence.*;
import javax.resource.spi.AuthenticationMechanism;

/**
 *
 * @author 7
 */
@Entity
@Table(name = "TEST_CASE")
@SequenceGenerator(name="seq", sequenceName="p1_seq")
public class JPATestCase implements Serializable {
    private static final long serialVersionUID = 1L;
   
    @Column(name = "TC_NAME")
    private String tcName;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id 
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="seq")
    @Column(name = "TC_ID")
    private BigInteger tcId;
    @Lob
    @Column(name = "TC_CONTENT")
    private String tcContent;
    @ManyToMany(targetEntity=JPATestSuite.class)
    @JoinTable(name = "SUITES_CASES", joinColumns = {
        @JoinColumn(name = "TC_ID", referencedColumnName = "TC_ID")}, inverseJoinColumns = {
        @JoinColumn(name = "SUITE_ID", referencedColumnName = "SUITE_ID")})
    private Set<JPATestSuite> testsuites;
   
    @ManyToMany(targetEntity=JPATheme.class)
    @JoinTable(name = "THEMES_CASES", joinColumns = {
        @JoinColumn(name = "TC_ID", referencedColumnName="TC_ID")}, inverseJoinColumns = {
        @JoinColumn(name = "THEME_ID", referencedColumnName="THEME_ID")})
    private Set<JPATheme> themes;
    
    
    @JoinColumn(name = "TYPE_ID", referencedColumnName = "TYPE_ID")
    @ManyToOne
    private JPATestType typeId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "testcase")
    private List<JPAAnswer> answers;
    
    @Column(name="case_desc")
    private String description;
    
    public JPATestCase() {
    }

    public JPATestCase(BigInteger tcId) {
        this.tcId = tcId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    
    public String getTcName() {
        return tcName;
    }

    public void setTcName(String tcName) {
        this.tcName = tcName;
    }

    public BigInteger getTcId() {
        return tcId;
    }

    public void setTcId(BigInteger tcId) {
        this.tcId = tcId;
    }

    public String getTcContent() {
        return tcContent;
    }

    public void setTcContent(String tcContent) {
        this.tcContent = tcContent;
    }

  
    public Set<JPATestSuite> getTestsuites() {
        return testsuites;
    }

    public void setTestsuites(Set<JPATestSuite> testsuites) {
        this.testsuites = testsuites;
    }

 
    public Set<JPATheme> getThemes() {
        return themes;
    }

    public void setThemes(Set<JPATheme> themes) {
        this.themes = themes;
    }

    public JPATestType getTypeId() {
        return typeId;
    }

    public void setTypeId(JPATestType typeId) {
        this.typeId = typeId;
    }

    public List<JPAAnswer> getAnswers() {
        return answers;
    }

    public void setAnswers(List<JPAAnswer> answers) {
        this.answers = answers;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tcId != null ? tcId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof JPATestCase)) {
            return false;
        }
        JPATestCase other = (JPATestCase) object;
        if ((this.tcId == null && other.tcId != null) || (this.tcId != null && !this.tcId.equals(other.tcId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "toProj.TestCase[ tcId=" + tcId + " ]";
    }
    
}
